/**
 * tigerrad
 * fall 2006
 */

#ifndef _SHADER_H
#define _SHADER_H

#include "Util.h"

/**
 * Compile a GLSL shader from a input stream.
 */
class Shader
{
	public:
		/**
		 * Constructor.  Compile the shader at path.
		 * This will exit(1) if the shader does not compile.
		 * @param path Path to shader file.  Will be the debug name.
		 * @param type GL_VERTEX_SHADER or GL_FRAGMENT_SHADER
		 */
		Shader(const std::string& path, GLenum type);

		/**
		 * Constructor.  Compile the supplied shader code.
		 * This will exit(1) if the shader does not compile.
		 * @param name Debug name
		 * @param code Shader code
		 * @param type GL_VERTEX_SHADER or GL_FRAGMENT_SHADER
		 */
		Shader(const std::string& name, const char* content, GLenum type);

		/**
		 * Return the OpenGL name (reference).
		 */
		GLuint getGLName() const { return _glName; }

		/**
		 * Return the debug name. 
		 */
		std::string getName() { return _name; }

	private:
		/**
		 * Utility to create/compile a shader
		 * @param content Shader code
		 * @param type GL_VERTEX_SHADER or GL_FRAGMENT_SHADER
		 */
		void createShader(const char* content, GLenum type);

		GLuint _glName;
		std::string _name;
};

typedef boost::shared_ptr<Shader> ShaderPtr;

#endif

